using System.Collections.Generic;
using UnityEngine;

public class EffectPool : MonoBehaviour
{
	private Transform m_transform;

	public static EffectPool instance;

	public Transform originalwatereffect;

	public List<Effectobj> wartereffect_enablelist;

	public List<Effectobj> watereffect_disablelist;

	private bool havewater;

	private float watertime;

	public float watertimelimit;

	public Transform originalterrainSmoke;

	public List<Effectobj> terrainsmoke_enablelist;

	public List<Effectobj> terrainsmoke_disablelist;

	private bool haveterrainsmoke;

	private float terrainsmoketime;

	public float terrainsmoketimelimit;

	public Transform lowhpsmoke;

	public List<Effectobj> lowhpsmoke_enablelist;

	public List<Effectobj> lowhpsmoke_disablelist;

	public Transform dieexplosion;

	public List<Effectobj> dieexplosion_enablelist;

	public List<Effectobj> dieexplosion_disablelist;

	public Transform missileexplosion;

	public List<Effectobj> missileexplosion_enablelist;

	public List<Effectobj> missileexplosion_disablelist;

	public Transform youdaodan;

	public List<Effectobj> youdaodan_enablelist;

	public List<Effectobj> youdaodan_disablelist;

	public Transform lowhpsmoke_ship;

	public List<Effectobj> lowhpsmoke_ship_enablelist;

	public List<Effectobj> lowhpsmoke_ship_disablelist;

	public Transform dieexplosion_ship;

	public List<Effectobj> dieexplosion_ship_enablelist;

	public List<Effectobj> dieexplosion_ship_disablelist;

	public Transform lowhpsmoke_building;

	public List<Effectobj> lowhpsmoke_build_enablelist;

	public List<Effectobj> lowhpsmoke_build_disablelist;

	public Effectobj tempobj;

	private void Awake()
	{
		if (instance == null)
		{
			instance = this;
		}
		m_transform = base.transform;
	}

	private void Update()
	{
		if (havewater)
		{
			watertime += Time.deltaTime;
			if (watertime > watertimelimit)
			{
				havewater = false;
				watertime = 0f;
			}
		}
		if (haveterrainsmoke)
		{
			terrainsmoketime += Time.deltaTime;
			if (terrainsmoketime > terrainsmoketimelimit)
			{
				haveterrainsmoke = false;
				terrainsmoketime = 0f;
			}
		}
	}

	public Effectobj GetEffectObj(EFFECTTYPE needtype)
	{
		if (GlobalInf.CurrentQuality < (Quality)50)
		{
			return null;
		}
		tempobj = null;
		switch (needtype)
		{
		case EFFECTTYPE.bulletwater:
			refwatereffect();
			break;
		case EFFECTTYPE.bulletterrain:
			refterrainsmoke();
			break;
		case EFFECTTYPE.lowhpsmoke:
			reflowhpsmoke();
			break;
		case EFFECTTYPE.lowhpsmoke_ship:
			reflowhpsmoke_ship();
			break;
		case EFFECTTYPE.diedexplosion:
			refdieexplosion();
			break;
		case EFFECTTYPE.missileExplosion:
			refmissileexplosion();
			break;
		case EFFECTTYPE.youdaodan:
			refyoudaodan();
			break;
		case EFFECTTYPE.diedexplosion_ship:
			refdieexplosion_ship();
			break;
		case EFFECTTYPE.lowhpsmoke_building:
			reflowhpsmoke_build();
			break;
		}
		return tempobj;
	}

	public void refyoudaodan()
	{
		if (youdaodan_disablelist.Count > 0)
		{
			tempobj = youdaodan_disablelist[0];
			youdaodan_disablelist.RemoveAt(0);
			youdaodan_enablelist.Add(tempobj);
		}
		else if (GlobalInf.CurrentQuality > (Quality)101)
		{
			tempobj = (UnityEngine.Object.Instantiate(youdaodan.gameObject) as GameObject).GetComponent<Effectobj>();
			youdaodan_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void refmissileexplosion()
	{
		if (missileexplosion_disablelist.Count > 0)
		{
			tempobj = missileexplosion_disablelist[0];
			missileexplosion_disablelist.RemoveAt(0);
			missileexplosion_enablelist.Add(tempobj);
		}
		else if (GlobalInf.CurrentQuality > (Quality)101)
		{
			tempobj = (UnityEngine.Object.Instantiate(missileexplosion.gameObject) as GameObject).GetComponent<Effectobj>();
			missileexplosion_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void refdieexplosion()
	{
		if (dieexplosion_disablelist.Count > 0)
		{
			tempobj = dieexplosion_disablelist[0];
			dieexplosion_disablelist.RemoveAt(0);
			dieexplosion_enablelist.Add(tempobj);
		}
		else
		{
			tempobj = (UnityEngine.Object.Instantiate(dieexplosion.gameObject) as GameObject).GetComponent<Effectobj>();
			dieexplosion_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void refdieexplosion_ship()
	{
		if (dieexplosion_ship_disablelist.Count > 0)
		{
			tempobj = dieexplosion_ship_disablelist[0];
			dieexplosion_ship_disablelist.RemoveAt(0);
			dieexplosion_ship_enablelist.Add(tempobj);
		}
		else
		{
			tempobj = (UnityEngine.Object.Instantiate(dieexplosion_ship.gameObject) as GameObject).GetComponent<Effectobj>();
			dieexplosion_ship_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void reflowhpsmoke()
	{
		if (lowhpsmoke_disablelist.Count > 0)
		{
			tempobj = lowhpsmoke_disablelist[0];
			lowhpsmoke_disablelist.RemoveAt(0);
			lowhpsmoke_enablelist.Add(tempobj);
		}
		else if (GlobalInf.CurrentQuality > (Quality)101 && GlobalInf.ishavespeedsmoke)
		{
			tempobj = (UnityEngine.Object.Instantiate(lowhpsmoke.gameObject) as GameObject).GetComponent<Effectobj>();
			lowhpsmoke_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void reflowhpsmoke_ship()
	{
		if (lowhpsmoke_ship_disablelist.Count > 0)
		{
			tempobj = lowhpsmoke_ship_disablelist[0];
			lowhpsmoke_ship_disablelist.RemoveAt(0);
			lowhpsmoke_ship_enablelist.Add(tempobj);
		}
		else if (GlobalInf.CurrentQuality > (Quality)101)
		{
			tempobj = (UnityEngine.Object.Instantiate(lowhpsmoke_ship.gameObject) as GameObject).GetComponent<Effectobj>();
			lowhpsmoke_ship_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void reflowhpsmoke_build()
	{
		if (lowhpsmoke_build_disablelist.Count > 0)
		{
			tempobj = lowhpsmoke_build_disablelist[0];
			lowhpsmoke_build_disablelist.RemoveAt(0);
			lowhpsmoke_build_enablelist.Add(tempobj);
		}
		else if (GlobalInf.CurrentQuality > (Quality)101)
		{
			tempobj = (UnityEngine.Object.Instantiate(lowhpsmoke_building.gameObject) as GameObject).GetComponent<Effectobj>();
			lowhpsmoke_build_enablelist.Add(tempobj);
			tempobj.transform.parent = m_transform;
		}
	}

	public void refterrainsmoke()
	{
		if (haveterrainsmoke)
		{
			tempobj = null;
		}
		else if (terrainsmoke_disablelist.Count > 0)
		{
			tempobj = terrainsmoke_disablelist[0];
			terrainsmoke_disablelist.RemoveAt(0);
			terrainsmoke_enablelist.Add(tempobj);
			haveterrainsmoke = true;
		}
		else if (GlobalInf.CurrentQuality > (Quality)101)
		{
			tempobj = (UnityEngine.Object.Instantiate(originalterrainSmoke.gameObject) as GameObject).GetComponent<Effectobj>();
			terrainsmoke_enablelist.Add(tempobj);
			haveterrainsmoke = true;
			tempobj.transform.parent = m_transform;
		}
	}

	public void refwatereffect()
	{
		if (havewater)
		{
			tempobj = null;
		}
		else if (watereffect_disablelist.Count > 0)
		{
			tempobj = watereffect_disablelist[0];
			watereffect_disablelist.RemoveAt(0);
			wartereffect_enablelist.Add(tempobj);
			havewater = true;
		}
		else if (GlobalInf.CurrentQuality > (Quality)101)
		{
			tempobj = (UnityEngine.Object.Instantiate(originalwatereffect.gameObject) as GameObject).GetComponent<Effectobj>();
			wartereffect_enablelist.Add(tempobj);
			havewater = true;
			tempobj.transform.parent = m_transform;
		}
	}

	public void RecycleEffect(EFFECTTYPE rectype, Effectobj b)
	{
		switch (rectype)
		{
		case EFFECTTYPE.bulletwater:
			watereffect_disablelist.Add(b);
			wartereffect_enablelist.RemoveAt(wartereffect_enablelist.IndexOf(b));
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.bulletterrain:
			terrainsmoke_disablelist.Add(b);
			terrainsmoke_enablelist.RemoveAt(terrainsmoke_enablelist.IndexOf(b));
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.lowhpsmoke:
			lowhpsmoke_disablelist.Add(b);
			lowhpsmoke_enablelist.RemoveAt(lowhpsmoke_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.lowhpsmoke_ship:
			lowhpsmoke_ship_disablelist.Add(b);
			lowhpsmoke_ship_enablelist.RemoveAt(lowhpsmoke_ship_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.diedexplosion:
			dieexplosion_disablelist.Add(b);
			dieexplosion_enablelist.RemoveAt(dieexplosion_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.missileExplosion:
			missileexplosion_disablelist.Add(b);
			missileexplosion_enablelist.RemoveAt(missileexplosion_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.youdaodan:
			youdaodan_disablelist.Add(b);
			youdaodan_enablelist.RemoveAt(youdaodan_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.diedexplosion_ship:
			dieexplosion_ship_disablelist.Add(b);
			dieexplosion_ship_enablelist.RemoveAt(dieexplosion_ship_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		case EFFECTTYPE.lowhpsmoke_building:
			lowhpsmoke_build_disablelist.Add(b);
			lowhpsmoke_build_enablelist.RemoveAt(lowhpsmoke_build_enablelist.IndexOf(b));
			b.transform.parent = m_transform;
			UnityVersionUtil.SetActiveRecursive(b.gameObject, state: false);
			break;
		}
	}

	private void OnDestroy()
	{
		if (instance != null)
		{
			instance = null;
		}
	}
}
